package me.zhengjie.modules.utils;

import cn.hutool.core.date.DateTime;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import me.zhengjie.modules.domain.enterprise.*;
import me.zhengjie.modules.domain.intellectual.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JsonUtils {

    public static Map<String, Object> JsonToEnterpriseInf(String json){
        JSONObject jsonObject = JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        EnterpriseInformation e=null;
        if(code.equals("0")){
            Map<String,Object> map=new HashMap<>();
            e=new EnterpriseInformation();
            JSONObject a1=jsonObject.getJSONObject("result");
            e.setHistoryNames(a1.getString("historyNames"));
            e.setRegStatus(a1.getString("regStatus"));
            e.setCancelDate(DateUtils.StringToDateTime(a1.getString("cancelDate")));
            e.setRegCapital(a1.getString("regCapital"));
            e.setCity(a1.getString("city"));
            e.setStaffNumRange(a1.getString("staffNumRange"));
            e.setIndustry(a1.getString("industry"));
            JSONArray a2=a1.getJSONArray("historyNameList");
            StringBuffer historyNameList=new StringBuffer();
            if(a2.size()>0){
                for (Object o : a2) {
                    historyNameList.append(o.toString()+"&");
                }
            }
            e.setHistoryNameList(historyNameList.toString());
            e.setBondNum(a1.getString("bondNum"));
            e.setType(a1.getInteger("type"));
            e.setBondName(a1.getString("bondName"));
            e.setUpdateTimes(DateUtils.StringToDateTime(a1.getString("updateTimes")));
            e.setRevokeDate(DateUtils.StringToDateTime(a1.getString("revokeDate")));
            e.setLegalPersonName(a1.getString("legalPersonName"));
            e.setRevokeReason(a1.getString("revokeReason"));
            e.setRegNumber(a1.getString("regNumber"));
            e.setProperty3(a1.getString("property3"));
            e.setCreditCode(a1.getString("creditCode"));
            e.setUsedBondName(a1.getString("usedBondName"));
            e.setFromTime(DateUtils.StringToDateTime(a1.getString("fromTime")));
            e.setApprovedTime(DateUtils.StringToDateTime(a1.getString("approvedTime")));
            e.setSocialStaffNum(a1.getInteger("socialStaffNum"));
            e.setAlias(a1.getString("alias"));
            e.setCompanyOrgType(a1.getString("companyOrgType"));
            e.setActualCapitalCurrency(a1.getString("actualCapitalCurrency"));
            e.setEyeId(a1.getLong("id"));
            e.setOrgNumber(a1.getString("orgNumber"));
            e.setCancelReason(a1.getString("cancelReason"));
            e.setToTime(DateUtils.StringToDateTime(a1.getString("toTime")));
            e.setEmail(a1.getString("email"));
            e.setActualCapital(a1.getString("actualCapital"));
            e.setEstiblishTime(DateUtils.StringToDateTime(a1.getString("estiblishTime")));
            e.setRegInstitute(a1.getString("regInstitute"));
            e.setTaxNumber(a1.getString("taxNumber"));
            e.setBusinessScope(a1.getString("businessScope"));
            e.setRegLocation(a1.getString("regLocation"));
            e.setRegCapitalCurrency(a1.getString("regCapitalCurrency"));
            e.setTags(a1.getString("tags"));
            e.setWebsiteList(a1.getString("websiteList"));
            e.setPhoneNumber(a1.getString("phoneNumber"));
            e.setDistrict(a1.getString("district"));
            e.setName(a1.getString("name"));
            e.setBondType(a1.getString("bondType"));
            e.setPercentileScore(a1.getString("percentileScore"));
            e.setIsMicroEnt(a1.getInteger("isMicroEnt"));
            e.setBase(a1.getString("base"));
            e.setPerTotal(a1.getJSONObject("staffList").getLong("total"));
            e.setCreateTime(new DateTime());
            e.setDeleteFlag(false);
            List<EnterprisePersonnelInformation> employees=new ArrayList<>();
            JSONArray a3=a1.getJSONObject("staffList").getJSONArray("result");
            if(a3.size()>0){
                StringBuffer str=null;
                JSONObject emp=null;
                EnterprisePersonnelInformation e1=null;
                for (Object o : a3) {
                    emp=(JSONObject)o;
                    e1=new EnterprisePersonnelInformation();
                    e1.setName(emp.getString("name"));
                    e1.setEyeId(emp.getLong("id"));
                    e1.setType(emp.getInteger("type"));
                    e1.setEnterpriseId(e.getId());
                    e1.setCreateTime(new DateTime());
                    e1.setDeleteFlag(false);
                    str=new StringBuffer();
                    for (Object typeJoin : emp.getJSONArray("typeJoin")) {
                        str.append(typeJoin+"&");
                    }
                    e1.setTypeJoin(str.toString());
                    employees.add(e1);
                }
            }
            e.setEmployees(employees);
            map.put("e",e);
            JSONObject a4=a1.getJSONObject("industryAll");
            map.put("category",a4.getString("category"));
            map.put("categoryBig",a4.getString("categoryBig"));
            map.put("categoryMiddle",a4.getString("categoryMiddle"));
            map.put("categorySmall",a4.getString("categorySmall"));
            return map;
        }
        return null;
    }

    public static List<EnterpriseShareholders> JsonToEnterpriseSha(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseShareholders> shareholdersList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray jsonArray=jsonObject.getJSONArray("items");
            EnterpriseShareholders shareholders=null;
            JSONObject a1=null;
            JSONObject a2=null;
            JSONArray array1=null;
            if(jsonArray.size()>0){
                for (Object o : jsonArray) {
                    shareholders=new EnterpriseShareholders();
                    a1= (JSONObject) o;
                    shareholders.setCgId(a1.getLong("cgid"));
                    shareholders.setName(a1.getString("name"));
                    shareholders.setLogo(a1.getString("logo"));
                    shareholders.setAlias(a1.getString("alias"));
                    shareholders.setEyeId(a1.getLong("id"));
                    shareholders.setType(a1.getInteger("type"));
                    shareholders.setHcgId(a1.getString("hcgid"));
                    array1=a1.getJSONArray("capital");
                    if(array1.size()>0){
                        a2=array1.getJSONObject(0);
                        shareholders.setAmomon(a2.getString("amomon"));
                        shareholders.setPaymet(a2.getString("paymet"));
                        shareholders.setTime(a2.getDate("time"));
                        shareholders.setPercent(a2.getString("percent"));
                    }
                    array1=a1.getJSONArray("capitalActl");
                    if(array1.size()>0){
                        a2=array1.getJSONObject(0);
                        shareholders.setActlAmomon(a2.getString("amomon"));
                        shareholders.setActlTime(a2.getDate("time"));
                        shareholders.setActlPercent(a2.getString("percent"));
                        shareholders.setActlPaymet(a2.getString("paymet"));
                    }
                    shareholders.setCreateTime(new DateTime());
                    shareholders.setDeleteFlag(false);
                    shareholdersList.add(shareholders);
                }
            }
            return shareholdersList;
        }
        return null;
    }

    public static List<EnterpriseShareholders> JsonToEnterpriseSha(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseShareholders> shareholdersList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray jsonArray=jsonObject.getJSONArray("items");
            EnterpriseShareholders shareholders=null;
            JSONObject a1=null;
            JSONObject a2=null;
            JSONArray array1=null;
            if(jsonArray.size()>0){
                for (Object o : jsonArray) {
                    shareholders=new EnterpriseShareholders();
                    a1= (JSONObject) o;
                    shareholders.setCgId(a1.getLong("cgid"));
                    shareholders.setName(a1.getString("name"));
                    shareholders.setLogo(a1.getString("logo"));
                    shareholders.setAlias(a1.getString("alias"));
                    shareholders.setEyeId(a1.getLong("id"));
                    shareholders.setType(a1.getInteger("type"));
                    shareholders.setHcgId(a1.getString("hcgid"));
                    array1=a1.getJSONArray("capital");
                    if(array1.size()>0){
                        a2=array1.getJSONObject(0);
                        shareholders.setAmomon(a2.getString("amomon"));
                        shareholders.setPaymet(a2.getString("paymet"));
                        shareholders.setTime(a2.getDate("time"));
                        shareholders.setPercent(a2.getString("percent"));
                    }
                    array1=a1.getJSONArray("capitalActl");
                    if(array1.size()>0){
                        a2=array1.getJSONObject(0);
                        shareholders.setActlAmomon(a2.getString("amomon"));
                        shareholders.setActlTime(a2.getDate("time"));
                        shareholders.setActlPercent(a2.getString("percent"));
                        shareholders.setActlPaymet(a2.getString("paymet"));
                    }
                    shareholders.setCreateTime(new DateTime());
                    shareholders.setDeleteFlag(false);
                    shareholdersList.add(shareholders);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/ic/holder/2.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i+"");
                    jsonObject=JSONObject.parseObject(json).getJSONObject("result");
                    jsonArray=jsonObject.getJSONArray("items");
                    if(jsonArray!=null&&jsonArray.size()>0){
                        for (Object o : jsonArray) {
                            shareholders=new EnterpriseShareholders();
                            a1= (JSONObject) o;
                            shareholders.setCgId(a1.getLong("cgid"));
                            shareholders.setName(a1.getString("name"));
                            shareholders.setLogo(a1.getString("logo"));
                            shareholders.setAlias(a1.getString("alias"));
                            shareholders.setEyeId(a1.getLong("id"));
                            shareholders.setType(a1.getInteger("type"));
                            shareholders.setHcgId(a1.getString("hcgid"));
                            array1=a1.getJSONArray("capital");
                            if(array1.size()>0){
                                a2=array1.getJSONObject(0);
                                shareholders.setAmomon(a2.getString("amomon"));
                                shareholders.setPaymet(a2.getString("paymet"));
                                shareholders.setTime(a2.getDate("time"));
                                shareholders.setPercent(a2.getString("percent"));
                            }
                            array1=a1.getJSONArray("capitalActl");
                            if(array1.size()>0){
                                a2=array1.getJSONObject(0);
                                shareholders.setActlAmomon(a2.getString("amomon"));
                                shareholders.setActlTime(a2.getDate("time"));
                                shareholders.setActlPercent(a2.getString("percent"));
                                shareholders.setActlPaymet(a2.getString("paymet"));
                            }
                            shareholders.setCreateTime(new DateTime());
                            shareholders.setDeleteFlag(false);
                            shareholdersList.add(shareholders);
                        }
                    }
                }
            }
            return shareholdersList;
        }
        return null;
    }

    public static IntellectualVo JsonToIntellectualVo(String json){
        List<Trademark> trademarkList=new ArrayList<>();
        List<Software> softwareList=new ArrayList<>();
        List<Works> worksList=new ArrayList<>();
        List<Website> websiteList=new ArrayList<>();
        List<Patent> patentList=new ArrayList<>();
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            JSONArray array=jsonObject.getJSONArray("tmList");
            JSONObject arrayJson=null;
            if(array!=null&&array.size()>0){
                Trademark trademark=null;
                for (Object o : array) {
                    arrayJson= (JSONObject) o;
                    trademark=new Trademark();
                    trademark.setRegNo(arrayJson.getString("regNo"));
                    trademark.setName(arrayJson.getString("tmName"));
                    trademark.setPic(arrayJson.getString("tmPic"));
                    trademark.setAppDate(arrayJson.getDate("appDate"));
                    trademark.setTmClass(arrayJson.getString("tmClass"));
                    trademark.setEyeId(arrayJson.getLong("id"));
                    trademark.setIntCls(arrayJson.getString("intCls"));
                    trademark.setApplicantCn(arrayJson.getString("applicantCn"));
                    trademark.setCategory(arrayJson.getString("category"));
                    trademark.setStatus(arrayJson.getString("status"));
                    trademark.setCreateTime(new DateTime());
                    trademark.setDeleteFlag(false);
                    trademarkList.add(trademark);
                }
            }
            array=jsonObject.getJSONArray("copyRegList");
            if(array!=null&&array.size()>0){
                Software software=null;
                for (Object o : array) {
                    arrayJson= (JSONObject) o;
                    software=new Software();
                    software.setRegTime(arrayJson.getDate("regTime"));
                    software.setRegNum(arrayJson.getString("regNum"));
                    software.setSimpleName(arrayJson.getString("simpleName"));
                    software.setFullName(arrayJson.getString("fullName"));
                    software.setAuthorNationality(arrayJson.getString("authorNationality"));
                    software.setEyeId(arrayJson.getLong("id"));
                    software.setCatNum(arrayJson.getString("catNum"));
                    software.setVersion(arrayJson.getString("version"));
                    software.setCreateTime(new DateTime());
                    software.setDeleteFlag(false);
                    softwareList.add(software);
                }
            }
            array=jsonObject.getJSONArray("copyRegWorksList");
            if(array!=null&&array.size()>0){
                Works works=null;
                for (Object o : array) {
                    arrayJson= (JSONObject) o;
                    works=new Works();
                    works.setPublishTime(arrayJson.getDate("publishTime"));
                    works.setFinishTime(arrayJson.getDate("finishTime"));
                    works.setRegTime(arrayJson.getDate("regTime"));
                    works.setRegNum(arrayJson.getString("regNum"));
                    works.setFullName(arrayJson.getString("fullName"));
                    works.setAuthorNationality(arrayJson.getString("authorNationality"));
                    works.setType(arrayJson.getString("type"));
                    works.setCreateTime(new DateTime());
                    works.setDeleteFlag(false);
                    worksList.add(works);
                }
            }
            array=jsonObject.getJSONArray("icpList");
            if(array!=null&&array.size()>0){
                Website website=null;
                StringBuffer str=null;
                JSONArray a1=null;
                for (Object o : array) {
                    arrayJson= (JSONObject) o;
                    website=new Website();
                    str=new StringBuffer();
                    a1=arrayJson.getJSONArray("webSite");
                    for (Object o1 : a1) {
                        str.append(o1.toString()+"&");
                    }
                    website.setWebSite(str.toString());
                    website.setLicense(arrayJson.getString("license"));
                    website.setYm(arrayJson.getString("ym"));
                    website.setCompanyType(arrayJson.getString("companyType"));
                    website.setExamineDate(arrayJson.getDate("examineDate"));
                    website.setWebName(arrayJson.getString("webName"));
                    website.setCompanyName(arrayJson.getString("companyName"));
                    website.setCreateTime(new DateTime());
                    website.setDeleteFlag(false);
                    websiteList.add(website);
                }
            }
            array=jsonObject.getJSONArray("patentList");
            if(array!=null&&array.size()>0){
                Patent patent=null;
                JSONObject a1=null;
                for (Object o : array) {
                    arrayJson= (JSONObject) o;
                    patent=new Patent();
                    patent.setAgent(arrayJson.getString("agent"));
                    patent.setPatentNum(arrayJson.getString("patentNum"));
                    patent.setTitle(arrayJson.getString("title"));
                    patent.setUuid(arrayJson.getString("uuid"));
                    patent.setApplicationTime(arrayJson.getDate("applicationTime"));
                    patent.setPatentStatus(arrayJson.getString("patentStatus"));
                    patent.setInventor(arrayJson.getString("inventor"));
                    patent.setEyeId(arrayJson.getLong("id"));
                    patent.setPubNumber(arrayJson.getString("pubNumber"));
                    a1=arrayJson.getJSONArray("lawStatus").getJSONObject(0);
                    patent.setLawDate(a1.getDate("date"));
                    patent.setLawDetail(a1.getString("detail"));
                    patent.setLawStatus(a1.getString("status"));
                    patent.setAddress(arrayJson.getString("address"));
                    patent.setAppNumber(arrayJson.getString("appNumber"));
                    patent.setAgency(arrayJson.getString("agency"));
                    patent.setGrantDate(arrayJson.getDate("grantDate"));
                    patent.setApplicantName(arrayJson.getString("applicantName"));
                    patent.setApplicationPublishTime(arrayJson.getDate("applicationPublishTime"));
                    patent.setPubDate(arrayJson.getDate("pubDate"));
                    patent.setPatentType(arrayJson.getString("patentType"));
                    patent.setImgUrl(arrayJson.getString("imgUrl"));
                    patent.setMainCatNum(arrayJson.getString("mainCatNum"));
                    patent.setPatentName(arrayJson.getString("patentName"));
                    patent.setPostCode(arrayJson.getString("postCode"));
                    patent.setAllCatNum(arrayJson.getString("allCatNum"));
                    patent.setApplicationPublishNum(arrayJson.getString("applicationPublishNum"));
                    a1=arrayJson.getJSONArray("priorityInfo").getJSONObject(0);
                    patent.setPriorityNum(a1.getString("priorityNum"));
                    patent.setPriorityDate(a1.getDate("priorityDate"));
                    patent.setIdPrivate(arrayJson.getString("idPrivate"));
                    patent.setCreateTime(new DateTime());
                    patent.setDeleteFlag(false);
                    patentList.add(patent);
                }
            }
            IntellectualVo intellectualVo=new IntellectualVo();
            intellectualVo.setTrademarkList(trademarkList);
            intellectualVo.setSoftwareList(softwareList);
            intellectualVo.setWorksList(worksList);
            intellectualVo.setWebsiteList(websiteList);
            intellectualVo.setPatentList(patentList);
            return intellectualVo;
        }
        return null;
    }

    public static List<EnterpriseProduct> JsonToProductList(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseProduct> productList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseProduct product=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    product=new EnterpriseProduct();
                    product.setDate(a1.getDate("date"));
                    product.setProduct(a1.getString("product"));
                    product.setCompanyName(a1.getString("companyName"));
                    product.setIcon(a1.getString("icon"));
                    product.setSetupDate(a1.getDate("setupDate"));
                    product.setYeWu(a1.getString("yewu"));
                    product.setJingpinProduct(a1.getString("jingpinProduct"));
                    product.setRound(a1.getString("round"));
                    product.setLocation(a1.getString("location"));
                    product.setHangYe(a1.getString("hangye"));
                    product.setValue(a1.getString("value"));
                    product.setIconOssPath(a1.getString("iconOssPath"));
                    product.setCreateTime(new DateTime());
                    product.setDeleteFlag(false);
                    productList.add(product);
                }
            }
            return productList;
        }
        return null;
    }

    public static List<EnterpriseProduct> JsonToProductList(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseProduct> productList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseProduct product=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    product=new EnterpriseProduct();
                    product.setDate(a1.getDate("date"));
                    product.setProduct(a1.getString("product"));
                    product.setCompanyName(a1.getString("companyName"));
                    product.setIcon(a1.getString("icon"));
                    product.setSetupDate(a1.getDate("setupDate"));
                    product.setYeWu(a1.getString("yewu"));
                    product.setJingpinProduct(a1.getString("jingpinProduct"));
                    product.setRound(a1.getString("round"));
                    product.setLocation(a1.getString("location"));
                    product.setHangYe(a1.getString("hangye"));
                    product.setValue(a1.getString("value"));
                    product.setIconOssPath(a1.getString("iconOssPath"));
                    product.setCreateTime(new DateTime());
                    product.setDeleteFlag(false);
                    productList.add(product);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/cd/findJingpin/2.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+1+"");
                    jsonObject=JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array!=null&&array.size()>0){
                        JSONObject a1=null;
                        EnterpriseProduct product=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            product=new EnterpriseProduct();
                            product.setDate(a1.getDate("date"));
                            product.setProduct(a1.getString("product"));
                            product.setCompanyName(a1.getString("companyName"));
                            product.setIcon(a1.getString("icon"));
                            product.setSetupDate(a1.getDate("setupDate"));
                            product.setYeWu(a1.getString("yewu"));
                            product.setJingpinProduct(a1.getString("jingpinProduct"));
                            product.setRound(a1.getString("round"));
                            product.setLocation(a1.getString("location"));
                            product.setHangYe(a1.getString("hangye"));
                            product.setValue(a1.getString("value"));
                            product.setIconOssPath(a1.getString("iconOssPath"));
                            product.setCreateTime(new DateTime());
                            product.setDeleteFlag(false);
                            productList.add(product);
                        }
                    }
                }
            }
            return productList;
        }
        return null;
    }

    public static List<EnterpriseInvestment> JsonToEnterpriseInvList(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseInvestment> investmentList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            String total=jsonObject.getString("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseInvestment investment=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    investment=new EnterpriseInvestment();
                    investment.setProduct(a1.getString("product"));
                    investment.setMoney(a1.getString("money"));
                    investment.setRound(a1.getString("round"));
                    investment.setProductId(a1.getString("product_id"));
                    investment.setLogo(a1.getString("logo"));
                    investment.setNewsUrl(a1.getString("news_url"));
                    investment.setNewsTitle(a1.getString("news_title"));
                    investment.setInvestDate(a1.getString("invest_date"));
                    investment.setCreateTime(new DateTime());
                    investment.setDeleteFlag(false);
                    investmentList.add(investment);
                }
            }
            return investmentList;
        }
        return null;
    }

    public static List<EnterpriseInvestment> JsonToEnterpriseInvList(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseInvestment> investmentList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseInvestment investment=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    investment=new EnterpriseInvestment();
                    investment.setProduct(a1.getString("product"));
                    investment.setMoney(a1.getString("money"));
                    investment.setRound(a1.getString("round"));
                    investment.setProductId(a1.getString("product_id"));
                    investment.setLogo(a1.getString("logo"));
                    investment.setNewsUrl(a1.getString("news_url"));
                    investment.setNewsTitle(a1.getString("news_title"));
                    investment.setInvestDate(a1.getString("invest_date"));
                    investment.setCreateTime(new DateTime());
                    investment.setDeleteFlag(false);
                    investmentList.add(investment);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/oi/investEvent/2.0?name="+enterpriseName+"&pageSize=20&pageNum="+i+"");
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array!=null&&array.size()>0){
                        JSONObject a1=null;
                        EnterpriseInvestment investment=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            investment=new EnterpriseInvestment();
                            investment.setProduct(a1.getString("product"));
                            investment.setMoney(a1.getString("money"));
                            investment.setRound(a1.getString("round"));
                            investment.setProductId(a1.getString("product_id"));
                            investment.setLogo(a1.getString("logo"));
                            investment.setNewsUrl(a1.getString("news_url"));
                            investment.setNewsTitle(a1.getString("news_title"));
                            investment.setInvestDate(a1.getString("invest_date"));
                            investment.setCreateTime(new DateTime());
                            investment.setDeleteFlag(false);
                            investmentList.add(investment);
                        }
                    }
                }
            }
            return investmentList;
        }
        return null;
    }

    public static List<EnterpriseFinancing> JsonToEnterpriseFinList(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseFinancing> financingList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            String total=jsonObject.getString("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                EnterpriseFinancing financing=null;
                JSONObject a1=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    financing=new EnterpriseFinancing();
                    financing.setMoney(a1.getString("money"));
                    financing.setRound(a1.getString("round"));
                    financing.setNewsUrl(a1.getString("newsUrl"));
                    financing.setCompanyName(a1.getString("companyName"));
                    financing.setPubTime(a1.getDate("pubTime"));
                    financing.setNewsTitle(a1.getString("newsTitle"));
                    financing.setInvestorName(a1.getString("investorName"));
                    financing.setShare(a1.getString("share"));
                    financing.setValue(a1.getString("value"));
                    financing.setCreateTime(new DateTime());
                    financing.setDeleteFlag(false);
                    financingList.add(financing);
                }
            }
            return financingList;
        }
        return null;
    }

    public static List<EnterpriseFinancing> JsonToEnterpriseFinList(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseFinancing> financingList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                EnterpriseFinancing financing=null;
                JSONObject a1=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    financing=new EnterpriseFinancing();
                    financing.setMoney(a1.getString("money"));
                    financing.setRound(a1.getString("round"));
                    financing.setNewsUrl(a1.getString("newsUrl"));
                    financing.setCompanyName(a1.getString("companyName"));
                    financing.setPubTime(a1.getDate("pubTime"));
                    financing.setNewsTitle(a1.getString("newsTitle"));
                    financing.setInvestorName(a1.getString("investorName"));
                    financing.setShare(a1.getString("share"));
                    financing.setValue(a1.getString("value"));
                    financing.setCreateTime(new DateTime());
                    financing.setDeleteFlag(false);
                    financingList.add(financing);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/cd/findHistoryRongzi/2.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i+"");
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array!=null&&array.size()>0){
                        EnterpriseFinancing financing=null;
                        JSONObject a1=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            financing=new EnterpriseFinancing();
                            financing.setMoney(a1.getString("money"));
                            financing.setRound(a1.getString("round"));
                            financing.setNewsUrl(a1.getString("newsUrl"));
                            financing.setCompanyName(a1.getString("companyName"));
                            financing.setPubTime(a1.getDate("pubTime"));
                            financing.setNewsTitle(a1.getString("newsTitle"));
                            financing.setInvestorName(a1.getString("investorName"));
                            financing.setShare(a1.getString("share"));
                            financing.setValue(a1.getString("value"));
                            financing.setCreateTime(new DateTime());
                            financing.setDeleteFlag(false);
                            financingList.add(financing);
                        }
                    }
                }
            }
            return financingList;
        }
        return null;
    }

    public static List<EnterpriseRecruitment> JsonToEnterpriseRecList(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseRecruitment> recruitmentList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            String total=jsonObject.getString("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                EnterpriseRecruitment recruitment=null;
                JSONObject a1=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    recruitment=new EnterpriseRecruitment();
                    recruitment.setEducation(a1.getString("education"));
                    recruitment.setCity(a1.getString("city"));
                    recruitment.setCompanyName(a1.getString("companyName"));
                    recruitment.setWebInfoPath(a1.getString("webInfoPath"));
                    recruitment.setSource(a1.getString("source"));
                    recruitment.setTitle(a1.getString("title"));
                    recruitment.setExperience(a1.getString("experience"));
                    recruitment.setCompanyGid(a1.getString("companyGid"));
                    recruitment.setSalary(a1.getString("salary"));
                    recruitment.setStartDate(a1.getDate("startDate"));
                    recruitment.setCreateTime(new DateTime());
                    recruitment.setDeleteFlag(false);
                    recruitmentList.add(recruitment);
                }
            }
            return recruitmentList;
        }
        return null;
    }

    public static List<EnterpriseRecruitment> JsonToEnterpriseRecList(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseRecruitment> recruitmentList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                EnterpriseRecruitment recruitment=null;
                JSONObject a1=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    recruitment=new EnterpriseRecruitment();
                    recruitment.setEducation(a1.getString("education"));
                    recruitment.setCity(a1.getString("city"));
                    recruitment.setCompanyName(a1.getString("companyName"));
                    recruitment.setWebInfoPath(a1.getString("webInfoPath"));
                    recruitment.setSource(a1.getString("source"));
                    recruitment.setTitle(a1.getString("title"));
                    recruitment.setExperience(a1.getString("experience"));
                    recruitment.setCompanyGid(a1.getString("companyGid"));
                    recruitment.setSalary(a1.getString("salary"));
                    recruitment.setStartDate(a1.getDate("startDate"));
                    recruitment.setCreateTime(new DateTime());
                    recruitment.setDeleteFlag(false);
                    recruitmentList.add(recruitment);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<=total/Contents.pageNum;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/m/employments/3.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i+"");
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array!=null&&array.size()>0){
                        EnterpriseRecruitment recruitment=null;
                        JSONObject a1=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            recruitment=new EnterpriseRecruitment();
                            recruitment.setEducation(a1.getString("education"));
                            recruitment.setCity(a1.getString("city"));
                            recruitment.setCompanyName(a1.getString("companyName"));
                            recruitment.setWebInfoPath(a1.getString("webInfoPath"));
                            recruitment.setSource(a1.getString("source"));
                            recruitment.setTitle(a1.getString("title"));
                            recruitment.setExperience(a1.getString("experience"));
                            recruitment.setCompanyGid(a1.getString("companyGid"));
                            recruitment.setSalary(a1.getString("salary"));
                            recruitment.setStartDate(a1.getDate("startDate"));
                            recruitment.setCreateTime(new DateTime());
                            recruitment.setDeleteFlag(false);
                            recruitmentList.add(recruitment);
                        }
                    }
                }
            }
            return recruitmentList;
        }
        return null;
    }

    public static List<EnterpriseAdministrative> JsonToEnterpriseAdmList(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseAdministrative> administrativeList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            String total=jsonObject.getString("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseAdministrative administrative=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    administrative=new EnterpriseAdministrative();
                    administrative.setLicenceContent(a1.getString("licenceContent"));
                    administrative.setLicenceDepartment(a1.getString("licenceDepartment"));
                    administrative.setAreaCode(a1.getString("areaCode"));
                    administrative.setEndDate(a1.getDate("endDate"));
                    administrative.setLicenceName(a1.getString("licenceName"));
                    administrative.setLicenseNumber(a1.getString("licenseNumber"));
                    administrative.setSource(a1.getString("source"));
                    administrative.setAuditType(a1.getString("auditType"));
                    administrative.setDataUpdateTime(a1.getString("dataUpdateTime"));
                    administrative.setDecisionDate(a1.getDate("decisionDate"));
                    administrative.setLegalPersonName(a1.getString("legalPersonName"));
                    administrative.setCreateTime(new DateTime());
                    administrative.setDeleteFlag(false);
                    administrativeList.add(administrative);
                }
            }
            return administrativeList;
        }
        return null;
    }

    public static List<EnterpriseAdministrative> JsonToEnterpriseAdmList(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseAdministrative> administrativeList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseAdministrative administrative=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    administrative=new EnterpriseAdministrative();
                    administrative.setLicenceContent(a1.getString("licenceContent"));
                    administrative.setLicenceDepartment(a1.getString("licenceDepartment"));
                    administrative.setAreaCode(a1.getString("areaCode"));
                    administrative.setEndDate(a1.getDate("endDate"));
                    administrative.setLicenceName(a1.getString("licenceName"));
                    administrative.setLicenseNumber(a1.getString("licenseNumber"));
                    administrative.setSource(a1.getString("source"));
                    administrative.setAuditType(a1.getString("auditType"));
                    administrative.setDataUpdateTime(a1.getString("dataUpdateTime"));
                    administrative.setDecisionDate(a1.getDate("decisionDate"));
                    administrative.setLegalPersonName(a1.getString("legalPersonName"));
                    administrative.setCreateTime(new DateTime());
                    administrative.setDeleteFlag(false);
                    administrativeList.add(administrative);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/m/getAdministrativeLicense/2.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i+"");
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array!=null&&array.size()>0){
                        JSONObject a1=null;
                        EnterpriseAdministrative administrative=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            administrative=new EnterpriseAdministrative();
                            administrative.setLicenceContent(a1.getString("licenceContent"));
                            administrative.setLicenceDepartment(a1.getString("licenceDepartment"));
                            administrative.setAreaCode(a1.getString("areaCode"));
                            administrative.setEndDate(a1.getDate("endDate"));
                            administrative.setLicenceName(a1.getString("licenceName"));
                            administrative.setLicenseNumber(a1.getString("licenseNumber"));
                            administrative.setSource(a1.getString("source"));
                            administrative.setAuditType(a1.getString("auditType"));
                            administrative.setDataUpdateTime(a1.getString("dataUpdateTime"));
                            administrative.setDecisionDate(a1.getDate("decisionDate"));
                            administrative.setLegalPersonName(a1.getString("legalPersonName"));
                            administrative.setCreateTime(new DateTime());
                            administrative.setDeleteFlag(false);
                            administrativeList.add(administrative);
                        }
                    }
                }
            }
            return administrativeList;
        }
        return null;
    }

    public static List<EnterpriseTax> JsonToEnterpriseTax(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseTax> taxList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            String total=jsonObject.getString("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseTax tax=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    tax=new EnterpriseTax();
                    tax.setYear(a1.getString("year"));
                    tax.setGrade(a1.getString("grade"));
                    tax.setName(a1.getString("name"));
                    tax.setType(a1.getString("type"));
                    tax.setIdNumber(a1.getString("idNumber"));
                    tax.setEvalDepartment(a1.getString("evalDepartment"));
                    tax.setCreateTime(new DateTime());
                    tax.setDeleteFlag(false);
                    taxList.add(tax);
                }
            }
            return taxList;
        }
        return null;
    }

    public static List<EnterpriseTax> JsonToEnterpriseTax(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseTax> taxList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseTax tax=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    tax=new EnterpriseTax();
                    tax.setYear(a1.getString("year"));
                    tax.setGrade(a1.getString("grade"));
                    tax.setName(a1.getString("name"));
                    tax.setType(a1.getString("type"));
                    tax.setIdNumber(a1.getString("idNumber"));
                    tax.setEvalDepartment(a1.getString("evalDepartment"));
                    tax.setCreateTime(new DateTime());
                    tax.setDeleteFlag(false);
                    taxList.add(tax);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/m/taxCredit/2.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i+"");
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array!=null&&array.size()>0){
                        JSONObject a1=null;
                        EnterpriseTax tax=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            tax=new EnterpriseTax();
                            tax.setYear(a1.getString("year"));
                            tax.setGrade(a1.getString("grade"));
                            tax.setName(a1.getString("name"));
                            tax.setType(a1.getString("type"));
                            tax.setIdNumber(a1.getString("idNumber"));
                            tax.setEvalDepartment(a1.getString("evalDepartment"));
                            tax.setCreateTime(new DateTime());
                            tax.setDeleteFlag(false);
                            taxList.add(tax);
                        }
                    }
                }
            }
            return taxList;
        }
        return null;
    }

    public static List<EnterpriseInformationProduct> JsonToEnterpriseInfProList(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseInformationProduct> productList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            String total=jsonObject.getString("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseInformationProduct product=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    product=new EnterpriseInformationProduct();
                    product.setBrief(a1.getString("brief"));
                    product.setClasses(a1.getString("classes"));
                    product.setFilterName(a1.getString("filterName"));
                    product.setIcon(a1.getString("icon"));
                    product.setName(a1.getString("name"));
                    product.setType(a1.getString("type"));
                    product.setUuid(a1.getString("uuid"));
                    product.setCreateTime(new DateTime());
                    product.setDeleteFlag(false);
                    productList.add(product);
                }
            }
            return productList;
        }
        return null;
    }

    public static List<EnterpriseInformationProduct> JsonToEnterpriseInfProList(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseInformationProduct> productList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                JSONObject a1=null;
                EnterpriseInformationProduct product=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    product=new EnterpriseInformationProduct();
                    product.setBrief(a1.getString("brief"));
                    product.setClasses(a1.getString("classes"));
                    product.setFilterName(a1.getString("filterName"));
                    product.setIcon(a1.getString("icon"));
                    product.setName(a1.getString("name"));
                    product.setType(a1.getString("type"));
                    product.setUuid(a1.getString("uuid"));
                    product.setCreateTime(new DateTime());
                    product.setDeleteFlag(false);
                    productList.add(product);
                }
            }
            if(total/Contents.pageNum>0){
                for (int i=2;i<3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/m/appbkInfo/2.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i+"");
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array!=null&&array.size()>0){
                        JSONObject a1=null;
                        EnterpriseInformationProduct product=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            product=new EnterpriseInformationProduct();
                            product.setBrief(a1.getString("brief"));
                            product.setClasses(a1.getString("classes"));
                            product.setFilterName(a1.getString("filterName"));
                            product.setIcon(a1.getString("icon"));
                            product.setName(a1.getString("name"));
                            product.setType(a1.getString("type"));
                            product.setUuid(a1.getString("uuid"));
                            product.setCreateTime(new DateTime());
                            product.setDeleteFlag(false);
                            productList.add(product);
                        }
                    }
                }
            }
            return productList;
        }
        return null;
    }

    public static EnterpriseAbstract JsonToEnterpriseAbs(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        if(code.equals("0")){
            EnterpriseAbstract enterpriseAbstract=new EnterpriseAbstract();
            enterpriseAbstract.setResult(jsonObject.getString("result"));
            enterpriseAbstract.setCreateTime(new DateTime());
            enterpriseAbstract.setDeleteFlag(false);
            return enterpriseAbstract;
        }
        return null;
    }

    public static List<EnterpriseInvestmentInstitutions> JsonToEnterpriseInvIns(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseInvestmentInstitutions> institutionsList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                EnterpriseInvestmentInstitutions institutions=null;
                JSONObject a1=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    institutions=new EnterpriseInvestmentInstitutions();
                    institutions.setJigouName(a1.getString("jigou_name"));
                    institutions.setArea(a1.getString("area"));
                    institutions.setOrgCode(a1.getString("orgCode"));
                    institutions.setImgPath(a1.getString("imgPath"));
                    institutions.setJigouDesc(a1.getString("desc"));
                    institutions.setFoundYear(a1.getString("foundYear"));
                    institutions.setCreateTime(new DateTime());
                    institutions.setDeleteFlag(false);
                    institutionsList.add(institutions);
                }
            }
            return institutionsList;
        }
        return null;
    }

    public static List<EnterpriseInvestmentInstitutions> JsonToEnterpriseInvIns(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseInvestmentInstitutions> institutionsList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array!=null&&array.size()>0){
                EnterpriseInvestmentInstitutions institutions=null;
                JSONObject a1=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    institutions=new EnterpriseInvestmentInstitutions();
                    institutions.setJigouName(a1.getString("jigou_name"));
                    institutions.setArea(a1.getString("area"));
                    institutions.setOrgCode(a1.getString("orgCode"));
                    institutions.setImgPath(a1.getString("imgPath"));
                    institutions.setJigouDesc(a1.getString("desc"));
                    institutions.setFoundYear(a1.getString("foundYear"));
                    institutions.setCreateTime(new DateTime());
                    institutions.setDeleteFlag(false);
                    institutionsList.add(institutions);
                }
            }
            if(total/Contents.pageNum>0){
                for(int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/cd/investOrg/2.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i+"");
                    jsonObject=JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    EnterpriseInvestmentInstitutions institutions=null;
                    JSONObject a1=null;
                    if(array!=null&&array.size()>0){
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            institutions=new EnterpriseInvestmentInstitutions();
                            institutions.setJigouName(a1.getString("jigou_name"));
                            institutions.setArea(a1.getString("area"));
                            institutions.setOrgCode(a1.getString("orgCode"));
                            institutions.setImgPath(a1.getString("imgPath"));
                            institutions.setJigouDesc(a1.getString("desc"));
                            institutions.setFoundYear(a1.getString("foundYear"));
                            institutions.setCreateTime(new DateTime());
                            institutions.setDeleteFlag(false);
                            institutionsList.add(institutions);
                        }
                    }
                }
            }
            return institutionsList;
        }
        return null;
    }

    public static Map<String, Object> JsonToPerIntroduction(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            System.out.println(jsonObject);
            String weibo=jsonObject.getString("weibo");
            String headUrl=jsonObject.getString("headUrl");
            String introduction=jsonObject.getString("introduction");
            Map<String, Object> map=new HashMap<>();
            map.put("weibo",weibo);
            map.put("headUrl",headUrl);
            map.put("introduction",introduction);
            return map;
        }
        return null;
    }

    public static List<EnterpriseLegalAction> JsonToEnterpriseLegal(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseLegalAction> legalActionList=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            System.out.println(jsonObject);
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array.size()>0){
                System.out.println(array);
                JSONObject a1=null;
                JSONObject a2=null;
                JSONArray a3=null;
                EnterpriseLegalAction legalAction=null;
                EnterpriseLegalPersons persons=null;
                List<EnterpriseLegalPersons> personsList=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    legalAction=new EnterpriseLegalAction();
                    legalAction.setDocType(a1.getString("docType"));
                    legalAction.setLawsuitUrl(a1.getString("lawsuitUrl"));
                    legalAction.setLawsuitH5Url(a1.getString("lawsuitH5Url"));
                    legalAction.setTitle(a1.getString("title"));
                    legalAction.setCourt(a1.getString("court"));
                    legalAction.setJudgeTime(a1.getDate("judgeTime"));
                    legalAction.setUuid(a1.getString("uuid"));
                    legalAction.setCaseNo(a1.getString("caseNo"));
                    legalAction.setCaseType(a1.getString("caseType"));
                    legalAction.setCaseReason(a1.getString("caseReason"));
                    legalAction.setCaseMoney(a1.getString("caseMoney"));
                    legalAction.setSubmitTime(a1.getDate("submitTime"));
                    legalAction.setEyeId(a1.getLong("id"));
                    legalAction.setCreateTime(new DateTime());
                    legalAction.setDeleteFlag(false);
                    a3=a1.getJSONArray("casePersons");
                    personsList=new ArrayList<>();
                    for (Object o1 : a3) {
                        a2= (JSONObject) o1;
                        persons=new EnterpriseLegalPersons();
                        persons.setRole(a2.getString("role"));
                        persons.setResult(a2.getString("result"));
                        persons.setGid(a2.getString("gid"));
                        persons.setEmotion(a2.getInteger("emotion"));
                        persons.setName(a2.getString("name"));
                        persons.setType(a2.getString("type"));
                        personsList.add(persons);
                    }
                    legalAction.setPersonsList(personsList);
                    legalActionList.add(legalAction);
                }
            }
            if(total/ Contents.pageNum>0){
                for(int i=2;i<=3;i++){
                    json= MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/jr/lawSuit/3.0?keyword="+enterpriseName+"&pageNum="+i+"&pageSize=20");
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    System.out.println(jsonObject);
                    array=jsonObject.getJSONArray("items");
                    if(array.size()>0){
                        System.out.println(array);
                        JSONObject a1=null;
                        JSONObject a2=null;
                        JSONArray a3=null;
                        EnterpriseLegalAction legalAction=null;
                        EnterpriseLegalPersons persons=null;
                        List<EnterpriseLegalPersons> personsList=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            legalAction=new EnterpriseLegalAction();
                            legalAction.setDocType(a1.getString("docType"));
                            legalAction.setLawsuitUrl(a1.getString("lawsuitUrl"));
                            legalAction.setLawsuitH5Url(a1.getString("lawsuitH5Url"));
                            legalAction.setTitle(a1.getString("title"));
                            legalAction.setCourt(a1.getString("court"));
                            legalAction.setJudgeTime(a1.getDate("judgeTime"));
                            legalAction.setUuid(a1.getString("uuid"));
                            legalAction.setCaseNo(a1.getString("caseNo"));
                            legalAction.setCaseType(a1.getString("caseType"));
                            legalAction.setCaseReason(a1.getString("caseReason"));
                            legalAction.setCaseMoney(a1.getString("caseMoney"));
                            legalAction.setSubmitTime(a1.getDate("submitTime"));
                            legalAction.setEyeId(a1.getLong("id"));
                            legalAction.setCreateTime(new DateTime());
                            legalAction.setDeleteFlag(false);
                            a3=a1.getJSONArray("casePersons");
                            personsList=new ArrayList<>();
                            for (Object o1 : a3) {
                                a2= (JSONObject) o1;
                                persons=new EnterpriseLegalPersons();
                                persons.setRole(a2.getString("role"));
                                persons.setResult(a2.getString("result"));
                                persons.setGid(a2.getString("gid"));
                                persons.setEmotion(a2.getInteger("emotion"));
                                persons.setName(a2.getString("name"));
                                persons.setType(a2.getString("type"));
                                personsList.add(persons);
                            }
                            legalAction.setPersonsList(personsList);
                            legalActionList.add(legalAction);
                        }
                    }
                }
            }
            return legalActionList;
        }
        return null;
    }

    public static List<EnterpriseAdministrativePenalty> JsonToEnterpriseAdmPenList(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<EnterpriseAdministrativePenalty> list=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            System.out.println(jsonObject);
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array.size()>0){
                System.out.println(array);
                JSONObject a1=null;
                EnterpriseAdministrativePenalty penalty=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    penalty=new EnterpriseAdministrativePenalty();
                    penalty.setDepartmentName(a1.getString("departmentName"));
                    penalty.setReason(a1.getString("reason"));
                    penalty.setEvidence(a1.getString("evidence"));
                    penalty.setPunishStatus(a1.getString("punishStatus"));
                    penalty.setRemark(a1.getString("remark"));
                    penalty.setSource(a1.getString("source"));
                    penalty.setType(a1.getString("type"));
                    penalty.setContent(a1.getString("content"));
                    penalty.setDecisionDate(a1.getDate("decisionDate"));
                    penalty.setLegalPersonName(a1.getString("legalPersonName"));
                    penalty.setPunishName(a1.getString("punishName"));
                    penalty.setPunishNumber(a1.getString("punishNumber"));
                    penalty.setTypeSecond(a1.getString("typeSecond"));
                    penalty.setCreateTime(new DateTime());
                    penalty.setDeleteFlag(false);
                    list.add(penalty);
                }
            }
            if(total/ Contents.pageNum>0){
                for(int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/mr/punishmentInfo/3.0?pageSize=20&keyword="+enterpriseName+"&pageNum="+i);
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array.size()>0){
                        JSONObject a1=null;
                        EnterpriseAdministrativePenalty penalty=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            penalty=new EnterpriseAdministrativePenalty();
                            penalty.setDepartmentName(a1.getString("departmentName"));
                            penalty.setReason(a1.getString("reason"));
                            penalty.setEvidence(a1.getString("evidence"));
                            penalty.setPunishStatus(a1.getString("punishStatus"));
                            penalty.setRemark(a1.getString("remark"));
                            penalty.setSource(a1.getString("source"));
                            penalty.setType(a1.getString("type"));
                            penalty.setContent(a1.getString("content"));
                            penalty.setDecisionDate(a1.getDate("decisionDate"));
                            penalty.setLegalPersonName(a1.getString("legalPersonName"));
                            penalty.setPunishName(a1.getString("punishName"));
                            penalty.setPunishNumber(a1.getString("punishNumber"));
                            penalty.setTypeSecond(a1.getString("typeSecond"));
                            penalty.setCreateTime(new DateTime());
                            penalty.setDeleteFlag(false);
                            list.add(penalty);
                        }
                    }
                }
            }
            return list;
        }
        return null;
    }

    public static List<Qualification>  JsonToQualification(String json){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<Qualification> list=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            System.out.println(jsonObject);
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array.size()>0){
                System.out.println(array);
                JSONObject a1=null;
                JSONObject a2=null;
                JSONArray a3=null;
                StringBuffer str1=null;
                StringBuffer str2=null;
                Qualification qualification=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    qualification=new Qualification();
                    qualification.setCertNo(a1.getString("certNo"));
                    qualification.setEndDate(a1.getDate("endDate"));
                    qualification.setCertificateName(a1.getString("certificateName"));
                    qualification.setEyeId(a1.getString("id"));
                    qualification.setStartDate(a1.getDate("startDate"));
                    qualification.setCreateTime(new DateTime());
                    qualification.setDeleteFlag(false);
                    a3=a1.getJSONArray("detail");
                    str1=new StringBuffer();
                    str2=new StringBuffer();
                    for (Object o1 : a3) {
                        a2= (JSONObject) o1;
                        str1.append(a2.getString("title")+"&");
                        str2.append(a2.getString("content")+"&");
                    }
                    qualification.setTitle(str1.toString());
                    qualification.setContent(str2.toString());
                    list.add(qualification);
                }
            }
            return list;
        }
        return null;
    }

    public static List<Qualification>  JsonToQualification(String json,String enterpriseName){
        JSONObject jsonObject= JSONObject.parseObject(json);
        System.out.println(jsonObject);
        String code=jsonObject.getString("error_code");
        List<Qualification> list=new ArrayList<>();
        if(code.equals("0")){
            jsonObject= JSONObject.parseObject(json).getJSONObject("result");
            System.out.println(jsonObject);
            Integer total=jsonObject.getInteger("total");
            JSONArray array=jsonObject.getJSONArray("items");
            if(array.size()>0){
                System.out.println(array);
                JSONObject a1=null;
                JSONObject a2=null;
                JSONArray a3=null;
                StringBuffer str1=null;
                StringBuffer str2=null;
                Qualification qualification=null;
                for (Object o : array) {
                    a1= (JSONObject) o;
                    qualification=new Qualification();
                    qualification.setCertNo(a1.getString("certNo"));
                    qualification.setEndDate(a1.getDate("endDate"));
                    qualification.setCertificateName(a1.getString("certificateName"));
                    qualification.setEyeId(a1.getString("id"));
                    qualification.setStartDate(a1.getDate("startDate"));
                    qualification.setCreateTime(new DateTime());
                    qualification.setDeleteFlag(false);
                    a3=a1.getJSONArray("detail");
                    str1=new StringBuffer();
                    str2=new StringBuffer();
                    for (Object o1 : a3) {
                        a2= (JSONObject) o1;
                        str1.append(a2.getString("title")+"&");
                        str2.append(a2.getString("content")+"&");
                    }
                    qualification.setTitle(str1.toString());
                    qualification.setContent(str2.toString());
                    list.add(qualification);
                }
            }
            if(total/ Contents.pageNum>0){
                for(int i=2;i<=3;i++){
                    json=MyHttpUtils.GetJson(Contents.token,"http://open.api.tianyancha.com/services/open/m/certificate/2.0?name="+enterpriseName+"&pageSize=20&pageNum="+i);
                    jsonObject= JSONObject.parseObject(json).getJSONObject("result");
                    array=jsonObject.getJSONArray("items");
                    if(array.size()>0){
                        System.out.println(array);
                        JSONObject a1=null;
                        JSONObject a2=null;
                        JSONArray a3=null;
                        StringBuffer str1=null;
                        StringBuffer str2=null;
                        Qualification qualification=null;
                        for (Object o : array) {
                            a1= (JSONObject) o;
                            qualification=new Qualification();
                            qualification.setCertNo(a1.getString("certNo"));
                            qualification.setEndDate(a1.getDate("endDate"));
                            qualification.setCertificateName(a1.getString("certificateName"));
                            qualification.setEyeId(a1.getString("id"));
                            qualification.setStartDate(a1.getDate("startDate"));
                            qualification.setCreateTime(new DateTime());
                            qualification.setDeleteFlag(false);
                            a3=a1.getJSONArray("detail");
                            str1=new StringBuffer();
                            str2=new StringBuffer();
                            for (Object o1 : a3) {
                                a2= (JSONObject) o1;
                                str1.append(a2.getString("title")+"&");
                                str2.append(a2.getString("content")+"&");
                            }
                            qualification.setTitle(str1.toString());
                            qualification.setContent(str2.toString());
                            list.add(qualification);
                        }
                    }
                }
            }
            return list;
        }
        return null;
    }
}
